import { createI18n } from "vue-i18n";
import zhCN from "./locales/zh_CH";
import enUS from "./locales/en_US";
import config from "@/configs/globalConfig";

const i18n = createI18n({
  legacy: false, // 使用 Composition API
  locale: config.lang,
  globalInjection: true, // 全局注册$t方法
  messages: {
    zh: zhCN,
    en: enUS,
  },
  datetimeFormats: {
    zh: {
      short: {
        year: "numeric",
        month: "short",
        day: "numeric",
      },
      long: {
        year: "numeric",
        month: "2-digit",
        day: "2-digit",
        hour: "2-digit",
        minute: "2-digit",
        // timeZoneName: "short",
      },
    },
    en: {
      short: {
        year: "numeric",
        month: "short",
        day: "numeric",
      },
      long: {
        year: "numeric", // 2-digit -> 两位显示 numeric -> 2023
        month: "2-digit",
        day: "2-digit",
        hour: "2-digit",
        minute: "2-digit",
        // timeZone: "UTC", // 转换为UTC时间
      },
    },
  },
  numberFormats: {
    zh: {
      currency: {
        style: "currency",
        currency: "CNY",
        currencyDisplay: "symbol",
      },
    },
    en: {
      currency: {
        style: "currency",
        currency: "USD",
        currencyDisplay: "symbol",
      },
    },
  },
});

export default i18n;
